$(function() {
  $.ajax({
    url: "/api/index/index",
    type: "get",
    success: function(res) {
      console.log(res.data);
      let htmlStr = template("m-menu-cd", res.data);
      $(".m-menu").html(htmlStr);
      let mtStr = template("brandList-zz", res.data);
      $("#zz").html(mtStr);
      let xpStr = template("newGoodsList-xp", res.data);
      $("#xp").html(xpStr);
      let rqStr = template("hotGoodsList-rq", res.data);
      $("#rq").html(rqStr);
      let flStr = template("categoryList-flsp", res.data);
      $("#fl").html(flStr);
      // 轮播图
      let lbStr = template("lunbotu_1", res.data);
      $(".wrapper1").html(lbStr);
      let jxStr = template("topicList-ztjx", res.data);
      $(".wrapper2").html(jxStr);
      // let brandDetail_Id = $(".item-1 a").attr("data-id");
      // console.log(brandDetail_Id);

      // 插件
      var swiper1 = new Swiper(".banner-swiper1", {
        spaceBetween: 30,
        centeredSlides: true,
        loop: true,
        autoplay: {
          delay: 2500,
          disableOnInteraction: false
        },
        pagination: {
          el: ".swiper-pagination",
          clickable: true
        },
        navigation: {
          nextEl: ".swiper-button-next",
          prevEl: ".swiper-button-prev"
        }
      });
      // two
      var swiper2 = new Swiper(".banner-swiper2", {
        spaceBetween: 30,
        centeredSlides: true,
        loop: true,
        autoplay: {
          // delay: 2500,
          disableOnInteraction: false
        },
        // pagination: {
        //   el: ".swiper-pagination",
        //   clickable: true
        // },
        navigation: {
          nextEl: ".swiper-button-next",
          prevEl: ".swiper-button-prev"
        }
      });
    }
  });
  $("#zz").on("click", "a", function(e) {
    // e.preventDefault();
    let brandDetail_Id = $(this).attr("data-id");
    console.log(brandDetail_Id);
    localStorage.setItem("brandDetail_Id", brandDetail_Id);
  });
  $("#xp").on("click", "a", function(e) {
    // e.preventDefault();
    let brandDetail_Id = $(this).attr("data-id");
    console.log(brandDetail_Id);
    localStorage.setItem("brandDetail_Id", brandDetail_Id);
  });
  $("#rq").on("click", "a", function(e) {
    // e.preventDefault();
    let brandDetail_Id = $(this).attr("data-id");
    console.log(brandDetail_Id);
    localStorage.setItem("brandDetail_Id", brandDetail_Id);
  });
  $("#fl").on("click", "a", function(e) {
    // e.preventDefault();
    let brandDetail_Id = $(this).attr("data-id");
    console.log(brandDetail_Id);
    localStorage.setItem("brandDetail_Id", brandDetail_Id);
  });
});
